{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "inside-discussion",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "There was no error!\n",
      "输出成功，请打开 test.xlsx 查看输出结果\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "# 1. 建交互控制台\n",
    "from yolib.convertter import pattern_copier\n",
    "copier = pattern_copier()\n",
    "# 2. 请求读取数据\n",
    "copier.read_data(data_file=r'.\\data\\0104郭薇.xls', idx=0, factory_name='河北新金', receipt='入仓单')\n",
    "\n",
    "# 11. 请求读取模板\n",
    "copier.read_pattern(r'.\\data\\出入库单模板.xlsx',0)\n",
    "\n",
    "# copier.tidy_data = copier.tidy_data[(copier.tidy_data.日期=='2021-7-23')]\n",
    "\n",
    "copier.tidy_data['供货方'] = '郭薇'\n",
    "copier.tidy_data['保管员'] = '梅林雪'\n",
    "copier.oto_loc.update({'F13': '保管员'})\n",
    "\n",
    "copier.tidy_data.货物名称 = copier.tidy_data.货物名称.str.replace('外购','')\n",
    "\n",
    "# 15. 请求写入sheet\n",
    "copier.write_in_sheet(gap_between_blocks_in_a_page=0,number_of_blocks_per_page=1)\n",
    "\n",
    "# 19. sheet 页面设置\n",
    "copier.page_setup(margins=copier.NARROWER,paperSize='0',scale=100,)\n",
    "\n",
    "# 21. 输出结果\n",
    "copier.output('test.xlsx')\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "chinese-remains",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     废钢\n",
       "1     废钢\n",
       "2     废钢\n",
       "3     废钢\n",
       "4     废钢\n",
       "5     废钢\n",
       "6     废钢\n",
       "7     废钢\n",
       "8     废钢\n",
       "9     废钢\n",
       "10    废钢\n",
       "11    废钢\n",
       "12    废钢\n",
       "13    废钢\n",
       "14    废钢\n",
       "15    废钢\n",
       "Name: 货物名称, dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "from datetime import datetime as dt\n",
    "\n",
    "df = pd.read_excel(r'.\\data\\0104郭薇.xls',0,skiprows=1)\n",
    "df.rename(columns={'品名':'货物名称','进厂时间':'日期','扣渣净重':'数量'},inplace=True)\n",
    "df = df[~df.日期.isna()]\n",
    "df.货物名称.str.replace('外购','')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "divine-bracelet",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
